fix(state): converge render-phase updates (v3.5.3)#49
Merged
Conversation
… output (v3.5.3)
A component that updated its own state during render (the derived-state pattern,
if x { setState(...) }) stored the new value and scheduled a commit, but the
component was never re-run — so the committed DOM showed a value the component had
not actually rendered (rendered 0, DOM showed 1) and never converged.
renderFunctionComponent now detects a render-phase update via a new
Runtime.activeRenderFiber flag (set only around the actual render call, distinct
from the ambient currentFiber so the SSR path and hook unit tests that set
currentFiber manually are unaffected) and re-runs the component to convergence,
bounded at 25 iterations with a diagnostic to guard an unconditional-setState
infinite loop. Matches React's "keeps restarting until there are no more new
updates."
The hook setter, when its owner == activeRenderFiber, marks the fiber
renderPhaseUpdate and returns without scheduling (the convergence loop handles
re-render). Found bug-hunting GWC's state management against React. Covered by
TestRenderPhaseUpdateConverges / DerivedStateOneStep / UnconditionalDoesNotHang;
full suite + native/wasm pass, no regression.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A component updating its own state during render committed a value it never rendered and never converged. renderFunctionComponent now re-runs to convergence (bounded 25, via a precise activeRenderFiber flag), matching React. Found bug-hunting state management. Full suite + native/wasm pass, no regression. Ships as v3.5.3.
🤖 Generated with Claude Code